<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no"/>
    <title>弹出购买页面</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css"/>
    <!--<link rel="stylesheet" type="text/css" href="../css/style.css"/>-->
    <link rel="stylesheet" type="text/css" href="../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../css/aui-flex.css"/>
    <link rel="stylesheet" type="text/css" href="../css/mui.min.css"/>
    <style>
        body {
            background: transparent;
            font-size: 14px;
            overflow: auto;

        }

    </style>
</head>

<body >
<div class="contain dispalyNone-unImportant">
    <div  class="aui-mask"></div>
    <footer class="aui-nav z-index99 height-auto " tapmode onclick="openToTwo('')">

        <div class=" "  id="goodInfo-content">



        </div>
        <div class="aui-btn   aui-btn-block radius-0 colorWhite  noBorder " tapmode onclick="goToOrder()" style="background: #ff3333;height: 55px;line-height: 55px;font-size: 16px;" >立即购买</div>
    </footer>
</div>
<script id="goodInfo-template" type="text/x-dot-template">
    <ul class="aui-list-view " style="margin-bottom: 45px;" >
        <li class="aui-list-view-cell aui-img">
            <img class="aui-img-object aui-pull-left" src="{{=it.goods_img}}">
            <div class="aui-img-body">
                <p class="aui-ellipsis-2">{{=it.goods_name}}</p>
                <p class="aui-ellipsis-2 aui-text-danger font-weight-700 aui-margin-t-5">￥{{=it.shop_price}}元</p>
            </div>
        </li>
        <li class="aui-list-view-cell aui-img ">
            <div class="line-height-34">
                <div class="aui-col-xs-6">
                    <p class="font-black"><h6>选择购买数量</h6></p>
                    <p class=""><h6>￥<em class="price">{{=it.shop_price}}</em> x <em class="count font-weight-700 font-black">1</em>=<em class=" totalMoney font-weight-700 aui-text-danger ">{{=it.shop_price}}</em>元</h6></p>
                </div>
                <div class="mui-numbox aui-col-xs-6 aui-pull-right" data-numbox-step='1' data-numbox-min='1' data-numbox-max='50'>
                    <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
                    <input  id="countInput" class="mui-input-numbox" type="number" value="1"/>
                    <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
                </div>
            </div>
        </li>
    </ul>
    <!--<div class="aui-btn   aui-btn-block radius-0 colorWhite  noBorder " tapmode onclick="goToOrder('{{=it.goods_id}}')" style="background: #ff3333;height: 55px;line-height: 55px;font-size: 16px;" >立即购买</div>-->
</script>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/jquery-1.11.3.js"></script>
<script type="text/javascript" src="../script/index.js"></script>
<script type="text/javascript" src="../script/mui.min.js"></script>
<script type="text/javascript">
    var goodId, companyName, money, orderId, orderNo,count=1;
    apiready = function () {
        api.parseTapmode();
        goodId = api.pageParam.goodId;
        $(".payMoney").text(money)
        //验证地址
        getStorageAll();
        //商品订单列表
//        alert(orderId)
        getGoodInfo();
    }

    $(document).on("change","#countInput",function () {
        count = $(this).val();
        $(this).closest("li").find(".count").text(count);
        var price = $(this).closest("li").find(".price").text();
        var total = price * count;
        $(this).closest("li").find(".totalMoney").text(total);
    })
    $(".aui-mask").click(function () {
        closeFrame();
    })

    function getGoodInfo() {
        showLoading()
        var url = "goods/info";
        var data = {};
        data["goods_id"] = goodId;
        getStorageAll();
//        alert(JSON.stringify(data))
        ajaxRequest(url, 'get', data, function (ret, err) {
            $(".contain").show();
            var content = $api.byId('goodInfo-content');
            var tpl = $api.byId('goodInfo-template').text;
            var tempFn = doT.template(tpl);
            $api.html(content, '');
            $api.html(content, tempFn(ret.data));
            hideLoading();
            mui('.mui-numbox').numbox();
        });
    }
    function goToOrder(id) {
//        user_id=1;
        if (!user_id) {
            api.toast({
                msg:"还没登录,请先登录"
            })
            setTimeout(function () {
                api.openWin({
                    name: 'loginPass_win',
                    url: 'loginPass_win.html'
                })
            },1500)

        } else {
            api.openFrame({
                bgColor: 'rgba(0,0,0,0)',
                name: 'orderConfirm_win',
                url: 'orderConfirm_win.html',
                bounces: false,
                rect: {
                    x: 0,
                    y: 0,
                    w: 'auto',
                    h: 'auto'
                },
                pageParam: {
                    goodId: goodId,
                    orderType:"singleGood",
                    count:count
                }
            });
        }
    }
</script>

</html>
